home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / decky.arc / MIDIKB.S < prev    next >
Text File  |  1989-06-15  |  5KB  |  119 lines

  1. start:
  2.          pea      install(pc)      ; superexec to set int vector
  3.          move.w   #38,-(a7)        ; and initialize midi ACIA
  4.          trap     #14
  5.          addq.l   #6,a7
  6.          clr.w    -(a7)
  7.          move.l   #$400,-(a7)      ; reserve space, keep process
  8.          move.w   #$31,-(a7)
  9.          trap     #1               ; done
  10. install:
  11.          pea      handler(pc)
  12.          move.l   (a7)+,$118       ; pointer keyboard/midi intrpt
  13.          move.b   #3,$fffffc04     ; master reset midi acia
  14.          move.b   #$96,$fffffc04   ; set for /64, 8bit, 1 s, no parity
  15.          rts
  16. handler: 
  17.          movem.l  d0-d7/a0-a6,-(sp); save registers
  18.          lea      $0,a5            ; clear a5 ( base page pointer )
  19. more:    jsr      midisrv
  20.          move.l   $dec(a5),a2      ; get keyboard addr
  21.          jsr      (a2)             ; service keyboard
  22.          btst     #4,$fffffa01     ; still interrupt
  23.          beq.s    more             ; yes
  24.          bclr     #6,$fffffa11     ; clear int service bit
  25.          movem.l  (sp)+,d0-d7/a0-a6
  26.          rte
  27. midisrv: move.b   d0,-(sp)
  28.          move.l   $de8(a5),a2      ; get midi addr
  29.          jsr      (a2)             ; service midi
  30.          move.b   (sp)+,d3         ; see if we got something
  31.          cmp.b    d0,d3            ; kludge to check for input
  32.          bne.s    doit
  33.          rts
  34. doit:    andi.l   #$ff,d0
  35.          move.l   d0,d3
  36.          cmp.b    #$55,d0          ; ignore codes below $56
  37.          bls      done
  38.          cmp.b    #$8d,d0          ; prevent alt insert
  39.          bne.s    noinsr           ; to avoid crashing!
  40.          btst     #3,$e1b          ; is it alt?
  41.          beq      lookup           ; nope
  42.          bra      done             ; yes, toss it
  43. noinsr:  cmp.b    #$b4,d0          ; is it metronome?
  44.          bne.s    norept
  45.          move.l   oldkey,d0        ; repeat last key
  46.          bra      almost
  47. norept:  cmp.b    #$bf,d3          ; is it tilde - modify keyboard
  48.          bne.s    notilde
  49.          move.w   #$01,d0          ; make it esc
  50.          bra      almost
  51. notilde: cmp.b    #$c9,d3          ; is it <>
  52.          bne.s    nogtlt
  53.          move.w   #$29,d0          ; make it tilde
  54.          bra      almost
  55. nogtlt:  cmp.b    #$bc,d3          ; is it backsp
  56.          bne.s    notdel
  57.          btst     #0,$e1b          ; is it shifted
  58.          bne.s    notdel
  59.          move.w   #$53,d0          ; make it del
  60.          bra      almost
  61. notdel:  cmp.b    #$ad,d3          ; handle shift codes
  62.          bmi      lookup
  63.          cmp.b    #$bb,d3
  64.          bpl      lookup           ; nope
  65.          move.b   $e1b,d2          ; get shift mask
  66.          cmp.b    #$af,d3          ; is it shift
  67.          bpl.s    arnd1
  68.          eori.b   #3,d2            ; toggle shift bits
  69.          bra.s    arnd5
  70. arnd1:   cmp.b    #$b0,d3
  71.          bpl.s    arnd2
  72.          bchg     #2,d2            ; toggle ctrl bit
  73.          bra.s    arnd5
  74. arnd2:   cmp.b    #$b1,d3
  75.          bpl.s    arnd3
  76.          bchg     #4,d2            ; toggle caps lock bit
  77.          bra.s    arnd5
  78. arnd3:   cmp.b    #$b2,d3
  79.          bpl.s    arnd4
  80.          bset     #3,d2            ; set alt bit
  81.          bra.s    arnd5
  82. arnd4:   cmp.b    #$b4,d3          ; all ups
  83.          bpl.s    arnd5
  84.          andi.b   #$f0,d2          ; clear shift,ctrl, and alt bits
  85. arnd5:   move.b   d2,$e1b          ; save new shift status
  86.          bra.s    done
  87. lookup:  lea      table(pc),a0     ; convert dec to st scan code
  88.          sub.w    #$56,d3
  89.          and.l    #$ff,d3
  90.          asl.l    #1,d3
  91.          adda.l   d3,a0
  92.          move.w   (a0),d0
  93. almost:  move.l   #$db0,a0         ; point to kbd iorec addr
  94.          lea      $0,a5
  95.          move.l   d0,oldkey
  96.          jsr      $fc2aa6          ; get scan code in buffer
  97.          bclr     #3,$e1b          ; clear alt shift
  98. done:    rts
  99. table:   dc.w     $3b,$3c,$3d,$3e,$3f,0,0,0,0,0,0,0,0,0 ; function keys
  100.          dc.w     $40,$41,$42,$43,$44,0,0,0,0,0,0,0,0
  101.          dc.w     $54,$55,$56,$57,0,0,0,0,0,0,0   ; shifted funct keys
  102.          dc.w     $58,$59,0,0,$5a,$5b,$5c,$5d,0,0,0,0,0,0
  103.          dc.w     $62,$0e,$61,$52,$0e,$47,0,0     ; keys abv cursor pad
  104.          dc.w     $70,0,$71,$72,$6d,$6e,$6f,$6a   ; numeric keypad
  105.          dc.w     $6b,$6c,$4e,$67,$68,$69,$4a
  106.          dc.w     $63,$64,$65,$66,0,0             ; pf keys
  107.          dc.w     $4b,$4d,$50,$48                 ; cursor keys
  108.          dc.w     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  109.          dc.w     $0e,$1c,$0f,$29,$02,$10,$1e,$2c,0 ; main keyboard
  110.          dc.w     $03,$11,$1f,$2d,0,0,$04,$12,$20,$2e
  111.          dc.w     0,$05,$13,$21,$2f,$39,0,$06,$14,$22,$30
  112.          dc.w     0,$07,$15,$23,$31,0,$08,$16,$24,$32,0
  113.          dc.w     $09,$17,$25,$33,0,$0a,$18,$26,$34,0
  114.          dc.w     $0b,$19,0,$27,$35,0,$0d,$1b,$2b,0
  115.          dc.w     $0c,$1a,$28,0,0,0
  116. oldkey:  dc.l     0
  117.          end
  118.  
  119.